package JFrame;

import entity.User;
import serive.ScService;
import serive.ScServiceImpl;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @author DONG
 */
public class TipsJDialog extends JDialog {
    ScService scService =new ScServiceImpl();

    public TipsJDialog(String id,int sc,String gameType) {
        Container pane = this.getContentPane();
        JDialog jDialog =this;
        this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
        this.setBounds(300,300,300,300);
        this.setVisible(true);
        JButton jButton = new JButton("点击保存游戏成绩，关闭窗口则不保存");
        jButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                boolean save = scService.saveSc(id, sc, gameType);
                if (save){
                    JOptionPane.showMessageDialog(pane, "保存成功，成功上传服务器", "！！！",JOptionPane.WARNING_MESSAGE);
                    jDialog.dispose();
                }else {
                    JOptionPane.showMessageDialog(pane, "保存失败", "！！！",JOptionPane.WARNING_MESSAGE);
                }
            }
        });
        pane.add(jButton);
    }




}
